<?php

/**
 * This is the model class for table "text".
 *
 * The followings are the available columns in table 'text':
 * @property string $id
 * @property string $lang_id
 * @property string $string
 *
 * The followings are the available model relations:
 * @property Block[] $blocksTitle
 * @property Block[] $blocksText
 * @property BlockCategory[] $blockCategoriesTitle
 * @property Menu[] $menusName
 * @property Seo[] $seosTitle
 * @property Seo[] $seosDescription
 * @property Seo[] $seosKeywords
 * @property Static[] $staticsName
 * @property Static[] $staticsText
 * @property Static[] $staticsPre
 * @property StaticCategory[] $staticCategoriesTitle
 * @property Lang $lang
 */
class Text extends AActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Text the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'text';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('string', 'required'),
			array('lang_id', 'length', 'max'=>10),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, lang_id, string', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'blocksTitle' => array(self::HAS_MANY, 'Block', 'title_id'),
			'blocksText' => array(self::HAS_MANY, 'Block', 'text_id'),
			'blockCategoriesTitle' => array(self::HAS_MANY, 'BlockCategory', 'title_id'),
			'menusName' => array(self::HAS_MANY, 'Menu', 'name_id'),
			'seosTitle' => array(self::HAS_MANY, 'Seo', 'title_id'),
			'seosDescription' => array(self::HAS_MANY, 'Seo', 'description_id'),
			'seosKeywords' => array(self::HAS_MANY, 'Seo', 'keywords_id'),
			'staticsName' => array(self::HAS_MANY, 'Static', 'name_id'),
			'staticsText' => array(self::HAS_MANY, 'Static', 'text_id'),
			'staticsPre' => array(self::HAS_MANY, 'Static', 'pre_id'),
			'staticCategoriesTitle' => array(self::HAS_MANY, 'StaticCategory', 'title_id'),
			'lang' => array(self::BELONGS_TO, 'Lang', 'lang_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'lang_id' => 'Lang',
			'string' => 'String',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id,true);
		$criteria->compare('lang_id',$this->lang_id,true);
		$criteria->compare('string',$this->string,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	public function getDeleteConfig(){
		return array();
	}
}